<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="https://v3.bootcss.com/favicon.ico">
<title>会员中心-文章列表</title>
<link href="/css/bootstrap/bootstrap.min.css" rel="stylesheet">
<link href="/css/page/blog.css" rel="stylesheet">
<link href="/css/font-awesome.min.css" rel="stylesheet">
</head>

<body>

	<#include "/nav.ftl"/>

	<div class="container">
		<div class="row" style="padding-top: 20px">
			<div class="table-responsive">
				<table class="table">
					<caption>文章列表</caption>
					<thead>
						<tr>
							<th>序号</th>
							<th>文章标题</th>
							<th>添加时间</th>
							<th>修改时间</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody>
						<#list articlePage.content as item>
						<tr>
							<td>${item_index+1}</td>
							<td>${item.title}</td>
							<td>${item.addDate}</td>
							<td>${item.editDate}</td>
							<td>
								<a class="btn btn-primary" onclick="editArticle(${item.id})">修改</a>
								<a class="btn btn-danger" onclick="delArticle(${item.id})">删除</a>
							</td>
						</tr>
						</#list>
					</tbody>
				</table>
			</div>
			<nav>
				<ul class="pager">
					<#if articlePage.hasPrevious()>
					<li>
						<a href="/article/list?page=${articlePage.previousPageable().getPageNumber()}">前一页</a>
					</li>
					</#if>
					<#if articlePage.hasNext()>
					<li>
						<a href="/article/list?page=${articlePage.nextPageable().getPageNumber()}">后一页</a>
					</li>
					</#if>
				</ul>
			</nav>
		</div>
		<!-- /.row -->

	</div>
	<!-- /.container -->
	<#include "/foot.ftl"/>
	<script src="/js/jquery/jquery.min.js"></script>
	<script src="/js/bootstrap/bootstrap.min.js"></script>
	<script type="text/javascript" src="/js/bootstrap/plugins/bootbox.js"></script>
	<script type="text/javascript" src="/js/common/common.js"></script>
	<script type="text/javascript" src="/js/common/myValidation.js"></script>
	<script type="text/javascript">
		function delArticle(id){
			var postData = {};
			postData.id = id;
			var loadingModel = bootbox.dialog({ message: '<div class="text-center"><i class="fa fa-spin fa-spinner"></i>请稍后</div>' });
			$.post("/article/del",postData, function(result){
				if(result.code == 200){
					location.reload();
				}else{
					bootbox.alert(result.mes);
				}
				loadingModel.hide();
			})
		}
		
		function editArticle(id){
			var redirectUrl = encodeURIComponent("/article/list");
			location.href = "/article/edit?redirectUrl="+redirectUrl+"&id="+id;
		}
	</script>
</body>

</html>